// 获取资产类型
import { defineStore } from 'pinia'
import { storage } from '../utils'
export default defineStore('assetCategoryStore', {
  state: () => ({
    assetCategory: JSON.parse(storage.get('ASSET_CATEGORY', '[]')) as any[],
  }),
  actions: {
    loadState() {
      const data = storage.get('ASSET_CATEGORY', '[]');
      this.$patch({ assetCategory: JSON.parse(data) });
    },

    setAllState(newState: Partial<any[]>) {
      storage.set('ASSET_CATEGORY', JSON.stringify(newState))
      this.$patch({ assetCategory: newState });
    },
    getAllState(): any[] {
      this.loadState();
      return this.assetCategory;
    },
  },
})
